<?php
namespace Framework\DiServices;

use Phalcon\Mvc\Router\Annotations;

class Router extends Annotations
{
    public function __construct(array $routers, $controllerNamespace)
    {
        parent::__construct(false);
        $this->removeExtraSlashes(true);
        $this->notFound(['controller' => 'Error', 'action' => 'notFound']);
        foreach ($routers as $routeName => $controllerName) {
            if (is_array($controllerName)) {
                foreach ($controllerName as $v) {
                    $this->addResource($controllerNamespace . '\\' . $v, '/' . $routeName);
                }
            } else {
                $this->addResource($controllerNamespace . '\\' . $controllerName, '/' . $routeName);
            }
        }
    }
}
